package com.deyuanyun.pic.ctrl.task.domain;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.ctrl.enumeration.EqptTypeEnum;
import com.deyuanyun.pic.settings.mapper.base.AttachmentMapper;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

/**
 * @author Jerry
 * @Description 腐蚀控制app日历规则
 * @date 2016-11-21
 */
public class ScheduleDto {
    private String id;//id
    private Date startTime;//起始时间
    private String frequency;//频次
    private Object alertAdvanceTime;//提醒触发时间(08:57)
    private String alertMode;//提醒提前方式(DAY：天、WEEK：周、MONTH：月)
    private Integer alertAdvanceCount;//提醒提前数量
    private Date endTime;//终止时间
    private String deviceObject;//设备对象
    private String deviceParam;//设备参数

    private String pipeLineId;//管道id
    private String fromPointId;//起始位置id
    private String fromName;//起点名称
    private Long fromMileage;//起始距离
    //  private String fromPointType;
    private String toPointId;//终止位置id
    private String toName;//终点名称
    private Long toMileage;//终止距离
    //private String toPointType;


    public String getId() {
        return id;
    }

    public Object getAlertAdvanceTime() {
        if (ObjectUtil.isNotNullEmpty(alertAdvanceTime)) {
            String[] time = ((String) alertAdvanceTime).split(":");
            if (time != null && time.length > 0) {
                int hourTime = (Integer.parseInt(time[0])) * 60 * 60 * 1000;
                int secondTime = (Integer.parseInt(time[1])) * 60 * 1000;
                return hourTime + secondTime;
            }
        }
        return null;
    }

    public void setAlertAdvanceTime(Object alertAdvanceTime) {
        this.alertAdvanceTime = alertAdvanceTime;
    }

    public String getAlertMode() {
        return alertMode;
    }

    public void setAlertMode(String alertMode) {
        this.alertMode = alertMode;
    }

    public Integer getAlertAdvanceCount() {
        return alertAdvanceCount;
    }

    public void setAlertAdvanceCount(Integer alertAdvanceCount) {
        this.alertAdvanceCount = alertAdvanceCount;
    }


    public void setId(String id) {
        this.id = id;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getDeviceObject() {
        if ("1HHHHH704BF1749EE0530E0AA8C08101".equals(deviceObject)) {
            return EqptTypeEnum.CPPOWER.toString();
        } else if ("1HHHHH704BF1749EE0530E0AA8C08103".equals(deviceObject)) {
            return EqptTypeEnum.REFERENCE.toString();
        } else if ("1HHHHH704BF1749EE0530E0AA8C08102".equals(deviceObject)) {
            return EqptTypeEnum.ANODESBED.toString();
        } else if ("1HHHHH704BF1749EE0530E0AA8C08106".equals(deviceObject)) {
            return EqptTypeEnum.INSULATEDJOINT.toString();
        } else if ("1HHHHH704BF1749EE0530E0AA8C08107".equals(deviceObject)) {
            return EqptTypeEnum.ANTISURGE.toString();
        } else if ("1HHHHH704BF1749EE0530E0AA8C08105".equals(deviceObject)) {
            return EqptTypeEnum.CPJUMPER.toString();
        } else if ("1HHHHH704BF1749EE0530E0AA8C08104".equals(deviceObject)) {
            return EqptTypeEnum.CPTESTSTATION.toString();
        } else if ("1HHHHH704BF1749EE0530E0AA8C08108".equals(deviceObject)) {
            return EqptTypeEnum.SAALANODE.toString();
        } else if ("1HHHHH704BF1749EE0530E0AA8C08109".equals(deviceObject)) {
            return EqptTypeEnum.CURRENTDRAINAGE.toString();
        }

        return null;
    }

    public void setDeviceObject(String deviceObject) {
        this.deviceObject = deviceObject;
    }

    public String getDeviceParam() {
        return CodeUtil.getName(deviceParam);
    }

    public void setDeviceParam(String deviceParam) {
        this.deviceParam = deviceParam;
    }

    public String getFrequency() {
        return frequency;
    }

    public void setFrequency(String frequency) {
        this.frequency = frequency;
    }

    public String getPipeLineId() {
        return pipeLineId;
    }

    public void setPipeLineId(String pipeLineId) {
        this.pipeLineId = pipeLineId;
    }

    public String getFromPointId() {
        return fromPointId;
    }

    public void setFromPointId(String fromPointId) {
        this.fromPointId = fromPointId;
    }

    public Long getFromMileage() {
        return fromMileage;
    }

    public void setFromMileage(Long fromMileage) {
        this.fromMileage = fromMileage;
    }

    public Long getToMileage() {
        return toMileage;
    }

    public void setToMileage(Long toMileage) {
        this.toMileage = toMileage;
    }

    public String getToPointId() {
        return toPointId;
    }

    public void setToPointId(String toPointId) {
        this.toPointId = toPointId;
    }

    public String getFromName() {
        return fromName;
    }

    public void setFromName(String fromName) {
        this.fromName = fromName;
    }

    public String getToName() {
        return toName;
    }

    public void setToName(String toName) {
        this.toName = toName;
    }
}
